#include <iostream>
#include <string>
#include <stack>
#include <unordered_map>

int main() {
    std::stack<char> list0;
    std::unordered_map<char, char> Posl{{')', '('}, {']', '['}, {'}', '{'}, {'>', '<'}};
    std::string Q;
    std::cout << "Ââåäèòå ñêîáî÷íóþ ïîñëåäîâàòåëüíîñòü: ";
    std::cin >> Q;

    for (char i : Q) {
        if (Posl.find(i) == Posl.end()) { // If it's an opening bracket
            list0.push(i);
        } else {
            if (list0.empty() || list0.top() != Posl[i]) {
                std::cout << "False\n";
                return 0;
            }
            list0.pop();
        }
    }

    std::cout << (list0.empty() ? "True" : "False") << std::endl;
    return 0;
}
